<%
  java.util.Vector strSearchNamesX = (java.util.Vector)pageContext.getAttribute("searchnamesx");
  
  if(strSearchNamesX == null){
    strSearchNamesX = new java.util.Vector();
  }
  String strCurSearchNameX = (String)pageContext.getAttribute("searchnamex");
  if(strCurSearchNameX == null)
    strCurSearchNameX = "";
  String strCurSearchValueX = (String)pageContext.getAttribute("searchvaluex");
  if(strCurSearchValueX == null)
    strCurSearchValueX = "";
  String strCurSearchValue1X = "";
  String strCurSearchValue2X = "";
  String comDisplayX = "";
  String speDisplayX = "none";
  for(int i=0;i<strSearchNamesX.size();i++)
  {
  	java.util.HashMap tempX = (java.util.HashMap)strSearchNamesX.elementAt(i);
  	String colnameX = (String)tempX.get("columnname");
  	String coltypeX = (String)tempX.get("columntype");
  	if(strCurSearchNameX.length() == 0)
  	  strCurSearchNameX = colnameX;
  	if(strCurSearchNameX.equals(colnameX))
  	{
  		if(!coltypeX.equalsIgnoreCase("varchar"))
  		{
        comDisplayX = "none";
        speDisplayX = "";  		  
  		}
      int csvpX = strCurSearchValueX.indexOf("^");      
      if(csvpX != -1 && !coltypeX.equalsIgnoreCase("varchar"))
      {
        strCurSearchValue1X = strCurSearchValueX.substring(0,csvpX);
        strCurSearchValue2X = strCurSearchValueX.substring(csvpX + 1);  
        strCurSearchValueX = "";   		
		  }
  		if(csvpX != -1 && coltypeX.equalsIgnoreCase("date"))
  		{
        strCurSearchValue1X = OvalTools.dateToString(strCurSearchValue1X,(String)session.getAttribute("dateformat"));
        strCurSearchValue2X = OvalTools.dateToString(strCurSearchValue2X,(String)session.getAttribute("dateformat"));   
  		  strCurSearchValueX = "";
  	  }
  	}	
  }

  String strCurOrderByColX = (String)pageContext.getAttribute("orderbycolumnx");
  if(strCurOrderByColX == null)
    strCurOrderByColX = "";
  String strCurOrderByTypeX = (String)pageContext.getAttribute("orderbytypex");
  if(strCurOrderByTypeX == null || strCurOrderByTypeX.length() == 0)
    strCurOrderByTypeX = "DESC";
  Integer nCurMaxItemX = (Integer)pageContext.getAttribute("maxitemx");
  if(nCurMaxItemX == null)
    nCurMaxItemX = new Integer("5");
  Integer nCurPageNoX = (Integer)pageContext.getAttribute("currentpagex");
  if(nCurPageNoX == null)
    nCurPageNoX = new Integer("0");
  Integer nCurCountX = (Integer)pageContext.getAttribute("countx");
  if(nCurCountX == null)
    nCurCountX = new Integer(0);
  Integer nCurTotalPageX = (Integer)pageContext.getAttribute("totalpagex");
  if(nCurTotalPageX == null)
    nCurTotalPageX = new Integer(0);
  Integer nCurEndIndexX = (Integer)pageContext.getAttribute("theendindexx");
  if(nCurEndIndexX == null)
    nCurEndIndexX = new Integer(0);
  boolean bCurHasPreX = false;
  boolean bCurHasNextX = false;  
  if(nCurCountX.intValue() != 0 && pageContext.getAttribute("hasprex") != null)
    bCurHasPreX = ((Boolean)pageContext.getAttribute("hasprex")).booleanValue();
  if(pageContext.getAttribute("hasnextx") != null)
    bCurHasNextX = ((Boolean)pageContext.getAttribute("hasnextx")).booleanValue();  
  int nCurRowCountX = 0;
  if(nCurPageNoX.intValue() < nCurTotalPageX.intValue() && nCurPageNoX.intValue() > 0)
    nCurRowCountX = nCurMaxItemX.intValue();
  else if(nCurPageNoX.intValue() == nCurTotalPageX.intValue() && nCurTotalPageX.intValue() != 0)
  {
    nCurRowCountX = nCurCountX.intValue()%nCurMaxItemX.intValue();
    if(nCurRowCountX == 0)
      nCurRowCountX = nCurMaxItemX.intValue();
  }
%>


<script language="JavaScript">
function changeSearchNameX()
{
  document.all.item("searchvaluex").value = "";    
  document.all.item("searchvalue1x").value = "";    
  document.all.item("searchvalue2x").value = "";    
  var searchnameX = document.all.item("searchnamealiasx").value;
  var arrX = searchnameX.split("^");  
  var searchtypeX = arrX[1];
  if(document.all.item("specx") != null && document.all.item("searchvaluex") != null  && document.all.item("searchvalue1x") != null && document.all.item("searchvalue2x") != null)
  { 
    if(searchtypeX == "date" || searchtypeX == "double" || searchtypeX == "integer")
    {     
      document.all.item("specx").style.display = "";
      document.all.item("searchvaluex").style.display = "none";    
    }else{
      document.all.item("specx").style.display = "none";
      document.all.item("searchvaluex").style.display = "";    
    }
  }
}
function summaryPrepareX(form,actionvalueX,orderbyname)
{
  if(form.searchnamealiasx != null && form.searchvaluex != null && form.searchvalue1x != null && form.searchvalue2x != null)
  { 
  	var valStringX = form.searchnamealiasx.value;
    var arrX = valStringX.split("^");  
    form.searchnamex.value = arrX[0];
    var searchtypeX = arrX[1];
    if(searchtypeX == "date" || searchtypeX == "Date")
    {
      var val1X = dateCheck(form.searchvalue1x.value,'yyyy-MM-dd','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>');
      var val2X = dateCheck(form.searchvalue2x.value,'yyyy-MM-dd','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>');
      if(val1X < 0 || val2X < 0)
      { 
        alert("<%= message.getMessageDesc("VALUE_MUST_BE_DATE",label.getLabelName("L_QuickSearch",false)) %>");
        form.searchvaluex.value = "";
        if(form.ispasscheckx != null)
          form.ispasscheckx.value = false;
      }
      else
        form.searchvaluex.value = val1X + "^" + val2X;
    }
    else if(searchtypeX == "integer" || searchtypeX == "Integer")
    {
      if(!isNumberNull(form.searchvalue1x.value) || !isNumberNull(form.searchvalue2x.value))
      { 
        alert("<%= message.getMessageDesc("VALUE_MUST_BE_INT",label.getLabelName("L_QuickSearch",false)) %>");
        form.searchvaluex.value = "";
        if(form.ispasscheckx != null)
          form.ispasscheckx.value = false;
      }
      else
        form.searchvaluex.value = form.searchvalue1x.value + "^" + form.searchvalue2x.value;
    }
    else if(searchtypeX == "double" || searchtypeX == "Double")
    {
      if(!isNumberic(form.searchvalue1x.value) || !isNumberic(form.searchvalue2x.value))
      { 
        alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER",label.getLabelName("L_QuickSearch",false)) %>");
        form.searchvaluex.value = "";
        if(form.ispasscheckx != null)
          form.ispasscheckx.value = false;
      }
      else
        form.searchvaluex.value = form.searchvalue1x.value + "^" + form.searchvalue2x.value;
    }
  }
  if(form.ispasscheckx != null)
    form.ispasscheckx.value = true;  
  if(actionvalueX == "orderby")
    editformX = page_orderbyX(form,orderbyname);
  else if(actionvalueX == "jumppage")
    editformX = page_jumpX(form);
  else if(actionvalueX == "pre")
    editformX = page_preX(form);
  else if(actionvalueX == "next")
    editformX = page_nextX(form);        
  else if(actionvalueX == "first")  
    editformX = page_firstX(form);
  else if(actionvalueX == "last")
    editformX = page_lastX(form); 
  else if(actionvalueX == "search")
    editformX = page_searchX(form); 
  else    
    return;   
  return editformX;
}

function page_preX(form)
{
  form.pageactionx.value="Pre";
  return form;
}
function page_nextX(form)
{
  form.pageactionx.value="Next";
  return form;
}
function page_firstX(form)
{
  form.pageactionx.value="Jump";
  form.jumppagex.value = "-2"
  return form;  
}
function page_lastX(form)
{
  form.pageactionx.value="Jump";
  form.jumppagex.value = "-1"
  return form;
}
function page_jumpX(form)
{
  form.pageactionx.value="Jump";
  if(form.jumppagex.value <= 0)
    form.jumppagex.value = 1;
  if(form.jumppagex.value > <%=JspHelper.filterNull( nCurTotalPageX )%>)
    form.jumppagex.value = <%=JspHelper.filterNull( nCurTotalPageX )%>;
  return form;
}

function page_orderbyX(form,ordercol)
{
  form.pageactionx.value = "OrderBy";
  if(form.orderbycolumnx.value.toUpperCase() == ordercol.toUpperCase())
  {
    if(form.orderbytypex.value.toUpperCase() == "ASC")
      form.orderbytypex.value = "DESC";
    else
      form.orderbytypex.value = "ASC";
  }
  else
    form.orderbycolumnx.value = ordercol;
  return form;
}
function page_searchX(form)
{
  form.pageactionx.value="OrderBy";
  return form;
}

</script>
